<!--主页-->
<template>
  <div>
    <Banner :bannerData="bannerData" v-if="bannerData"></Banner>
    <Nav>
        <template v-slot:nav1>通知公告</template>
        <template v-slot:nav2>岗位招聘</template>
        <template v-slot:nav3>投递记录</template>
        <template v-slot:nav4>账户管理</template>
    </Nav>
    <div>
      <ScrollBar :scrollBarData="scrollBarData" v-if="scrollBarData"></ScrollBar>
      <Notice :noticeData="noticeData" v-if="noticeData"></Notice>
  </div>
  </div>
</template>

<script setup>
import { inject, ref } from 'vue'
import Banner from '@/components/banner.vue'
import Nav from '@/components/nav.vue'
import ScrollBar from '@/components/scrollBar.vue'
import Notice from '@/components/notice.vue'
const $root = inject('$root')
const $axios = inject('$axios')
//广告栏数据
const bannerData = ref([])
//滚动栏数据
const scrollBarData = ref([])
const  noticeData=ref([])
//获取广告栏数据
const getBannerData = () => {
  return $axios.get($root + `/banner/get/`)
}
//获取通知公告
const getNoticeData = () => {
  return $axios.get($root + `/notice/`)
}
//获取滚动栏数据
const getScrollBarData = () => {
  return $axios.get($root + `/live/get/`)
}
//发起并发请求
$axios.all([getBannerData(), getScrollBarData(),getNoticeData()])
  .then($axios.spread(function (bannerRes, scrollBarRes,noticeRes) {
    // console.log(bannerRes)
    bannerData.value = bannerRes.data.data
    scrollBarData.value = scrollBarRes.data.data
    noticeData.value = noticeRes.data.data.data
    // console.log('bannerRes',bannerRes)
    // console.log('scrollBarRes',scrollBarRes)
  }));
</script>
